package com.chenyi.algorithm.search;

import java.util.ArrayList;
import java.util.List;

/**
 * 线性查找
 * @author chenyi
 * @className LinearSearch
 * @date 2022/4/5 19:37
 */
public class LinearSearch {

    public static void main(String[] args) {
        int[] arr = {1, 323, 22, 33, 11, 1, 3, 55, 6, 3};
        List<Integer> search = search(arr, 1);
        System.out.println(search);
    }

    public static List<Integer> search(int[] arr, int value) {
        List<Integer> numbers = new ArrayList<>();
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == value) {
                numbers.add(i);
            }
        }
        return numbers;
    }

}
